package org.rebluh.hulunbuirtravelnetworkbackendframework.controller;

import org.rebluh.hulunbuirtravelnetworkbackendframework.domain.Image;
import org.rebluh.hulunbuirtravelnetworkbackendframework.service.ImageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Optional;

@RestController
@RequestMapping("/img")
public class ImageController {
    @Autowired
    private ImageService imageService;

    //添加图片
    @PostMapping
    public Image createImage(@RequestBody Image image) {
        return imageService.createImage(image);
    }

    //根据hulber表获取对应的图片
    @GetMapping("/{id}")
    public List<Image> getImageByToHulberId(@PathVariable String id) {
        return imageService.getImageByToHulberId(id);
    }

    //获取所有图片
    @GetMapping
    public List<Image> getAllImages() {
        return imageService.getAllImage();
    }
}
